﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>

using namespace std;

typedef long long LL;
const int N = 1010;
int n, m, q;
LL f[N][N];//二维差分矩阵

//对x1,y1到x2,y2区域差分矩阵操作
void insert(int x1, int y1, int x2, int y2,int k)
{
	f[x1][y1] += k;
	f[x1][y2 + 1] -= k;
	f[x2 + 1][y1] -= k;
	f[x2 + 1][y2 + 1] += k;
}
int main()
{
	cin >> n >> m >> q;
	//构建差分矩阵
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			int tmp;
			cin >> tmp;
			//i,j为左上⻆,i,j为右下⻆的矩阵,统⼀加上x
			insert(i,j,i,j,tmp);
		}
	}

	int x1, y1, x2, y2, k;
	//对矩阵进行操作(相当于对原矩阵子矩阵数据操作）
	while (q--)
	{
		cin >> x1 >> y1 >> x2 >> y2 >> k;
		insert(x1, y1, x2, y2, k);
	}

	//输出操作后的原数组
	for (int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= m; ++j)
		{
			//利用前缀和还原出原矩阵
			LL res = f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + f[i][j];
			cout << res << ' ';

		}
		cout << endl;
	}

	return 0;
}